import '../video_model.dart';
import 'module_detail_model.dart';

class ModuleConfig {
  // "hasPay": true,
  bool? hasPay;

  // "mid": "string",
  String? mid;

  // "name": "string",
  String? name;

  // "price": 0
  int? price;

  ModuleConfig.fromJson(Map<String, dynamic> json) {
    hasPay = json['hasPay'];
    mid = json['mid'];
    name = json['name'];
    price = json['price'];
  }
}

//亚模块模型
class ModuleData {
  String? id;
  String? moduleName;
  int? type; //1、首页(原首页视频) 2、社区 3、暗网 4、动漫 5、漫画 6、小说, 7 黄油, 8图集, 9 有声小说, 10  种子,11  禁区
  /*
  NewPageShowType    // 1 首页最新/推荐展示类型
HJShowType         // 2 模块普通海角系样式
AllSectionShowType // 3 全专题组合样式
HengSlideShowType  // 4 (17岁)单排专题横滑动展示
ActressShowType    // 5 女优网黄展示样式
*/
  int? showType;
  int? permission;
  int? style; //
  bool? limitedTime;

  bool? isAW; // 是否为暗圈

  bool? hasPay; // 是否为需要支付

  int? price; // 支付金额

  // 暗网
  bool get needCheck {
    return (price ?? 0) > 0;
  }

  bool get isACG {
    return type == 4 || type == 5 || type == 6;
  }

  ModuleData({this.moduleName, this.type, this.id, this.showType});

  ModuleData.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    moduleName = json['moduleName'];
    type = json['type'];
    showType = json['showType'];
    permission = json['permission'];
    style = json['style'];
    price = json['price'];
    limitedTime = json['limitedTime'];
    isAW = json['isAW'];
  }

  Map<String, dynamic> toJson() {
    return {
      "id": id,
      "moduleName": moduleName,
      "type": type,
      "showType": showType,
      "permission": permission,
      "style": style,
      "price": price,
      "limitedTime": limitedTime,
      "isAW": isAW,
    };
  }
}

class HomePlateModel {
  List<ModuleData>? videos; //首页-视频
  List<ModuleData> get videosUI {
    List<ModuleData> list = [];
    ModuleData moduleData = ModuleData(moduleName: "关注", showType: -11, id: "GuanZhu_home");
    list.add(moduleData);
    list.addAll(videos ?? []);
    return list;
  } //首页-视频
  List<ModuleData>? community; //社区
  List<ModuleData>? deepWeb; //暗网
  List<ModuleData>? novel; //文字小说
  List<ModuleData>? audio; //有声小说
  List<ModuleData>? seed; //种子
  List<ModuleData>? forbidden; //禁区
  List<ModuleData>? _pics; //图集
  List<ModuleData> get picsUi {
    //图集
    List<ModuleData> tabs = [];
    // showtype = 2,列表
    tabs.add(ModuleData(moduleName: '热门推荐', type: -100, showType: 2));
    tabs.addAll(_pics ?? []);
    return tabs;
  }

  List<ModuleData>? _game; //黄游
  List<ModuleData> get gameUi {
    //黄游
    List<ModuleData> tabs = [];
    // showtype = 2,列表
    tabs.add(ModuleData(moduleName: '热门推荐', type: -101, showType: 2));
    tabs.addAll(_game ?? []);
    return tabs;
  }

  HomePlateModel.fromJson(Map<String, dynamic> json) {
    //1.首页
    videos = (List.from(json['videos'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //2.暗网
    deepWeb = (List.from(json['deepWeb'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //3.社区
    community = (List.from(json['community'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //4.图集
    _pics = (List.from(json['pics'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //5.文字小说
    novel = (List.from(json['novel'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //6.黄游
    _game = (json['game'] as List?)?.map((e) => ModuleData.fromJson(e)).toList();
    //7.有声小说
    audio = (List.from(json['audio'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //8.种子
    seed = (List.from(json['seed'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
    //9.禁区
    forbidden = (List.from(json['forbidden'] ?? [])).map((e) => ModuleData.fromJson(e)).toList();
  }
}

class HomeCacheData {
  ModuleDetailModel? dataModel;
  int? currentPage;
  List<VideoModel>? videoArr;
  int? guessLikeSortType;
  int? guessLikePage;

  HomeCacheData({
    this.dataModel,
    this.currentPage,
    this.videoArr,
    this.guessLikeSortType,
    this.guessLikePage,
  });
}

Map<String, HomeCacheData?> homeListTabDataCache = {};
